'use strict';
var clientApp = angular.module('clientApp');

clientApp.directive('cmsMap', ['$rootScope', 'Constant', 'App',  'cmsService', function($rootScope, Constant, App, cmsService) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            scope.$watch('contactUs.address', function (newVal, oldVal) {
                if (newVal) {
                    $rootScope.baiduMap = new BMap.Map("baidu-map")
                    $rootScope.baiduMap.centerAndZoom(new BMap.Point(), 11);
                    var local = new BMap.LocalSearch($rootScope.baiduMap, {
                        renderOptions:{map: $rootScope.baiduMap}
                    });
                    local.search(newVal);
                }
            });
        }
    };
}]);

